<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>Class: tinymce.dom.Selection</title>
<meta name="generator" content="MoxieDoc" />

<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/grids.css" />
<link rel="stylesheet" type="text/css" href="css/general.css" />

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
	google.load("jquery", "1.3");
</script>
<script type="text/javascript" src="js/jquery.treeview.min.js"></script>
<script type="text/javascript" src="js/general.js"></script>
</head>
<body>
<div class="classDetailsContent">
<h1>tinymce.dom.Selection</h1>
<table class="classDetails">
<tr>
<td class="first">Namespace</td>
<td class="last">tinymce.dom</td>
</tr>
<tr>
<td class="first">Class</td>
<td class="last">Selection</td>
</tr>
</table>
<div class="classDescription">This class handles text and control selection it's an crossbrowser utility class.
Consult the TinyMCE Wiki API for more details and examples on how to use this class.</div>
<div class="summaryLists">
<h2>Public Methods</h2>
<table class="Methods summary">
<thead>
<tr>
<th>Method</th>
<th>Defined By</th>
</tr>
</thead>
<tbody>
<tr>
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#Selection">Selection</a>(dom:<a href="class_tinymce.dom.DOMUtils.html">DOMUtils</a>, win:Window, serializer:<a href="class_tinymce.dom.Serializer.html">Serializer</a>)</div>
<div class="summary">Constructs a new selection instance.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr class="even">
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#collapse">collapse</a>(b:Boolean):void</div>
<div class="summary">Collapse the selection to start or end of range.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr>
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#getBookmark">getBookmark</a>(si:Boolean):Object</div>
<div class="summary">Returns a bookmark location for the current selection.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr class="even">
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#getContent">getContent</a>(s:Object):String</div>
<div class="summary">Returns the selected contents using the DOM serializer passed in to this class.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr>
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#getEnd">getEnd</a>():Element</div>
<div class="summary">Returns the end element of a selection range.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr class="even">
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#getNode">getNode</a>():Element</div>
<div class="summary">Returns the currently selected element or the common ancestor element for both start and end of the selection.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr>
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#getRng">getRng</a>(w3c:Boolean):Range</div>
<div class="summary">Returns the browsers internal range object.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr class="even">
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#getSel">getSel</a>():Selection</div>
<div class="summary">Returns the browsers internal selection object.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr>
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#getStart">getStart</a>():Element</div>
<div class="summary">Returns the start element of a selection range.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr class="even">
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#isCollapsed">isCollapsed</a>():Boolean</div>
<div class="summary">Returns true/false if the selection range is collapsed or not.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr>
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#moveToBookmark">moveToBookmark</a>(bookmark:Object):Boolean</div>
<div class="summary">Restores the selection to the specified bookmark.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr class="even">
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#select">select</a>(n:Element, c:Boolean):Element</div>
<div class="summary">Selects the specified element.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr>
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#setContent">setContent</a>(h:String, s:Object):void</div>
<div class="summary">Sets the current selection to the specified content.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr class="even">
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#setNode">setNode</a>(n:Element):Element</div>
<div class="summary">Sets the current selection to the specified DOM element.</div>
</td>
<td class="last">Selection</td>
</tr>
<tr>
<td class="first">
<div>
<a class="memberName" href="class_tinymce.dom.Selection.html#setRng">setRng</a>(r:Range):void</div>
<div class="summary">Changes the selection to the specified DOM range.</div>
</td>
<td class="last">Selection</td>
</tr>
</tbody>
</table>
</div>
<div class="detailsList">
<div class="details">
<h2>Method details</h2>
<div class="memberDetails" id="Selection">
<h3>Selection<span class="memberType">constructor</span>
</h3>
<code class="syntax">public 
						function Selection(dom:<a href="class_tinymce.dom.DOMUtils.html">DOMUtils</a>, win:Window, serializer:<a href="class_tinymce.dom.Serializer.html">Serializer</a>)</code>
<div class="memberDescription">Constructs a new selection instance.
</div>
<h4>Parameters</h4>
<table class="params">
<tr>
<td class="first">dom:<a href="class_tinymce.dom.DOMUtils.html">DOMUtils</a>
</td>
<td class="last">DOMUtils object reference.</td>
</tr>
<tr>
<td class="first">win:Window</td>
<td class="last">Window to bind the selection object to.</td>
</tr>
<tr>
<td class="first">serializer:<a href="class_tinymce.dom.Serializer.html">Serializer</a>
</td>
<td class="last">DOM serialization class to use for getContent.</td>
</tr>
</table>
</div>
<div class="memberDetails" id="collapse">
<h3>collapse<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function collapse(b:Boolean):void</code>
<div class="memberDescription">Collapse the selection to start or end of range.
</div>
<h4>Parameters</h4>
<table class="params">
<tr>
<td class="first">b:Boolean</td>
<td class="last">Optional boolean state if to collapse to end or not. Defaults to start.</td>
</tr>
</table>
</div>
<div class="memberDetails" id="getBookmark">
<h3>getBookmark<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function getBookmark(si:Boolean):Object</code>
<div class="memberDescription">Returns a bookmark location for the current selection. This bookmark object
can then be used to restore the selection after some content modification to the document.
</div>
<h4>Parameters</h4>
<table class="params">
<tr>
<td class="first">si:Boolean</td>
<td class="last">Optional state if the bookmark should be simple or not. Default is complex.</td>
</tr>
</table>
<h4>Returns</h4>
<div class="returns">Object - Bookmark object, use moveToBookmark with this object to restore the selection.</div>
</div>
<div class="memberDetails" id="getContent">
<h3>getContent<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function getContent(s:Object):String</code>
<div class="memberDescription">Returns the selected contents using the DOM serializer passed in to this class.
</div>
<h4>Parameters</h4>
<table class="params">
<tr>
<td class="first">s:Object</td>
<td class="last">Optional settings class with for example output format text or html.</td>
</tr>
</table>
<h4>Returns</h4>
<div class="returns">String - Selected contents in for example HTML format.</div>
</div>
<div class="memberDetails" id="getEnd">
<h3>getEnd<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function getEnd():Element</code>
<div class="memberDescription">Returns the end element of a selection range. If the end is in a text
node the parent element will be returned.
</div>
<h4>Returns</h4>
<div class="returns">Element - End element of selection range.</div>
</div>
<div class="memberDetails" id="getNode">
<h3>getNode<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function getNode():Element</code>
<div class="memberDescription">Returns the currently selected element or the common ancestor element for both start and end of the selection.
</div>
<h4>Returns</h4>
<div class="returns">Element - Currently selected element or common ancestor element.</div>
</div>
<div class="memberDetails" id="getRng">
<h3>getRng<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function getRng(w3c:Boolean):Range</code>
<div class="memberDescription">Returns the browsers internal range object.
</div>
<h4>Parameters</h4>
<table class="params">
<tr>
<td class="first">w3c:Boolean</td>
<td class="last">Forces a compatible W3C range on IE.</td>
</tr>
</table>
<h4>Returns</h4>
<div class="returns">Range - Internal browser range object.</div>
</div>
<div class="memberDetails" id="getSel">
<h3>getSel<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function getSel():Selection</code>
<div class="memberDescription">Returns the browsers internal selection object.
</div>
<h4>Returns</h4>
<div class="returns">Selection - Internal browser selection object.</div>
</div>
<div class="memberDetails" id="getStart">
<h3>getStart<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function getStart():Element</code>
<div class="memberDescription">Returns the start element of a selection range. If the start is in a text
node the parent element will be returned.
</div>
<h4>Returns</h4>
<div class="returns">Element - Start element of selection range.</div>
</div>
<div class="memberDetails" id="isCollapsed">
<h3>isCollapsed<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function isCollapsed():Boolean</code>
<div class="memberDescription">Returns true/false if the selection range is collapsed or not. Collapsed means if it's a caret or a larger selection.
</div>
<h4>Returns</h4>
<div class="returns">Boolean - true/false state if the selection range is collapsed or not. Collapsed means if it's a caret or a larger selection.</div>
</div>
<div class="memberDetails" id="moveToBookmark">
<h3>moveToBookmark<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function moveToBookmark(bookmark:Object):Boolean</code>
<div class="memberDescription">Restores the selection to the specified bookmark.
</div>
<h4>Parameters</h4>
<table class="params">
<tr>
<td class="first">bookmark:Object</td>
<td class="last">Bookmark to restore selection from.</td>
</tr>
</table>
<h4>Returns</h4>
<div class="returns">Boolean - true/false if it was successful or not.</div>
</div>
<div class="memberDetails" id="select">
<h3>select<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function select(n:Element, c:Boolean):Element</code>
<div class="memberDescription">Selects the specified element. This will place the start and end of the selection range around the element.
</div>
<h4>Parameters</h4>
<table class="params">
<tr>
<td class="first">n:Element</td>
<td class="last">HMTL DOM element to select.</td>
</tr>
<tr>
<td class="first">c:Boolean</td>
<td class="last">Bool state if the contents should be selected or not on non IE browser.</td>
</tr>
</table>
<h4>Returns</h4>
<div class="returns">Element - Selected element the same element as the one that got passed in.</div>
</div>
<div class="memberDetails" id="setContent">
<h3>setContent<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function setContent(h:String, s:Object):void</code>
<div class="memberDescription">Sets the current selection to the specified content. If any contents is selected it will be replaced
with the contents passed in to this function. If there is no selection the contents will be inserted
where the caret is placed in the editor/page.
</div>
<h4>Parameters</h4>
<table class="params">
<tr>
<td class="first">h:String</td>
<td class="last">HTML contents to set could also be other formats depending on settings.</td>
</tr>
<tr>
<td class="first">s:Object</td>
<td class="last">Optional settings object with for example data format.</td>
</tr>
</table>
</div>
<div class="memberDetails" id="setNode">
<h3>setNode<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function setNode(n:Element):Element</code>
<div class="memberDescription">Sets the current selection to the specified DOM element.
</div>
<h4>Parameters</h4>
<table class="params">
<tr>
<td class="first">n:Element</td>
<td class="last">Element to set as the contents of the selection.</td>
</tr>
</table>
<h4>Returns</h4>
<div class="returns">Element - Returns the element that got passed in.</div>
</div>
<div class="memberDetails last" id="setRng">
<h3>setRng<span class="memberType">method</span>
</h3>
<code class="syntax">public 
						function setRng(r:Range):void</code>
<div class="memberDescription">Changes the selection to the specified DOM range.
</div>
<h4>Parameters</h4>
<table class="params">
<tr>
<td class="first">r:Range</td>
<td class="last">Range to select.</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</body>
</html>
